package com.spyz.hdfs_api;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.net.URI;

public class P2_Hdfs_api_put_1 {
    public static void main(String[] args) throws Exception {


        URI uri = new URI("hdfs://master:8020");

        Configuration conf = new Configuration();

        String user = "root";

        FileSystem fs = FileSystem.get(uri, conf,user);

        // 参数1：表示删除原始数据
        // 参数2：是否允许覆盖
        // 参数3：原始数据路径
        // 参数4：目标数据路径
        fs.copyFromLocalFile(
                false,
                false,
                new Path("./data/word.txt"),
                new Path("/hdfs_api")
        );

        fs.close();
    }
}
